# !/usr/bin/env python
# encoding: utf-8
'''
  @author: HJW
  @license: (C) Copyright 2013-2017, Node Supply Chain Manager Corporation Limited.
  @contact: hejunwang01@126.com
  @file: models.py
  @time: 2022/7/10 0010 下午 13:04
  @desc:
  '''

import datetime
# 避免产生循环引用的情况,所以另外存一个位置
from dbs import db

from sqlalchemy import  DateTime

# 用户表
class MyUser(db.Model):
    __tablename__ = 'auto_user'
    id = db.Column(db.Integer, primary_key=True,autoincrement=True)
    # 用户名 ,密码
    name = db.Column(db.String(255), unique=True, index=True)
    passwd = db.Column(db.String(255))
    # 角色
    role = db.Column(db.String(255))
    # 创建时间
    createTime = db.Column(db.DateTime, default=datetime.datetime.now)
    # 状态
    status = db.Column(db.Boolean,default=True)

class Tdd(db.Model):
    __tablename__ = 'tdd'
    id = db.Column(db.Integer, primary_key=True,autoincrement=True)
    # 描述
    desc = db.Column(db.String(255), unique=True, index=True)
    params = db.Column(db.String(255))
    # 角色
    check = db.Column(db.String(255))
    # 创建时间
    createTime = db.Column(db.DateTime, default=datetime.datetime.now)
    # 状态
    status = db.Column(db.Boolean,default=True)


class MiniResult(db.Model):
    __tablename__="miniresult"
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    # 创建时间
    createTime = db.Column(db.DateTime, default=datetime.datetime.now)
    projectname = db.Column(db.String(255))
    taskid = db.Column(db.String(255))
    #结果
    result = db.Column(db.String(255))


class ApiResult(db.Model):
    __tablename__="apiresult"
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    # 创建时间
    createTime = db.Column(db.DateTime, default=datetime.datetime.now)
    projectname = db.Column(db.String(255))
    taskid = db.Column(db.String(255))
    #结果
    result = db.Column(db.String(255))

    def __str__(self):
        return 'ApiResult{projectname=%s,taskid=%s ,result=%s}' % (self.projectname, self.taskid,self.result)


class OverView(db.Model):
    # data: ['接口API', '小程序测试', 'UI自动化测试', '爬虫', '容器启动', '新增用户']
    __tablename__ = "overview"
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    createTime = db.Column(db.DateTime, default=datetime.datetime.now)
    apitestcount = db.Column(db.Integer)
    minitestcount = db.Column(db.Integer)
    uitestcount = db.Column(db.Integer)
    spidertestcount = db.Column(db.Integer)
    dockertestcount = db.Column(db.Integer)
    useraddcount = db.Column(db.Integer)
    def __str__(self):
        return 'OverView{createTime=%s,apitestcount=%d ,' \
               'minitestcount=%d,uitestcount=%d ,' \
               'spidertestcount=%d,dockertestcount=%d ,' \
               'useraddcount=%d}' %(self.createTime, self.apitestcount,self.minitestcount,self.uitestcount,self.spidertestcount,self.dockertestcount,self.useraddcount)



class ProTestCase(db.Model):
    __tablename__ = 'protestcase'
    id = db.Column(db.Integer, primary_key=True,autoincrement=True)
    # 描述名称
    pro_name = db.Column(db.String(255), unique=True, index=True)
    # 创建时间
    pro_createtime = db.Column(db.DateTime, default=datetime.datetime.now)
    # 更新时间
    pro_lastuptime = db.Column(db.DateTime, default=datetime.datetime.now)

    def __str__(self):
        return 'ProTestCase { id =%d ,pro_name =%s }' %(self.id ,self.pro_name)




